import React from "react";

export default function CommentList({ list, handleDel, showOwner }) {
    // const showList = list.filter(item => {
    //     if (showOwner) {
    //         return item.username === '思聪'
    //     }
    //     return item
    // })
    // const showList = list.filter(item => (showOwner ? item.username === '思聪' : true))
    // const showList = list.filter(item => (!showOwner || item.username === '思聪'))

    return (
        <ul>
            {!list.length ? (<div>暂无数据</div>) : (
                list.map(item => {
                    return (
                        <li key={item.id}>
                            <h3>评论人: {item.username}</h3>
                            <p>评论内容： {item.content}</p>
                            <button onClick={() => handleDel(item.id)}>删除</button>
                        </li>
                    );
                })
            )}
        </ul>
    );
}
